package com.lsk.division.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {

    /**
     * 处理静态资源
     * @param registry
     * @author tyg
     * @date 2020-09-02 10:26
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /*
         * addResourceHandler是访问路径前缀，参数可设置多个，以逗号分隔，例：/image/**,/css/**
         * addResourceLocations是对应的资源路径，也可以设置多个。
         */
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/templates/");
    }
}